// import '@babel/polyfill'
import Vue from 'vue'

import Cookies from 'js-cookie'

import 'normalize.css/normalize.css' // a modern alternative to CSS resets
import Element from 'element-ui'
import $ from 'jquery'
import moment from 'moment'
import Charts from 'v-charts'
import _ from 'lodash'
import './styles/element-variables.scss'
import '@/styles/index.scss' // global css
import '@/assets/fonts/2.11.1/index.css' // element-ui@2.11.1 全部的icon定义

import App from './App'
import store from './store'
import router from './router'

import i18n, { momentLanguage } from './lang' // internationalization
import directive from './directive' // 全局注册指令
import './icons' // icon
import './permission' // permission control
import * as filters from './filters' // global filters

Vue.use(Element, {
  size: Cookies.get('size') || 'medium', // set element-ui default size
  i18n: (key, value) => i18n.t(key, value)
})
Vue.use(Charts)
Vue.use(directive)

// register global utility filters
Object.keys(filters).forEach(key => {
  Vue.filter(key, filters[key])
})

Vue.config.productionTip = false

// 全局使用的moment插件,moment的国际化暂时用多语言的设置
moment.locale(momentLanguage())
Vue.prototype.moment = moment

Vue.prototype.$ = $
Vue.prototype._ = _

// 网络请求
import httpRequest from '@/utils/baseRequest.js'
Vue.prototype.$httpRequest = httpRequest

import api from './api/'
Vue.prototype.$api = api

import constant from './constant'
// TODO:全局变量统一添加$，待重构历史代码完成后去除下面一行
Vue.prototype.constant = constant
Vue.prototype.$constant = constant

// 全局日期时间函数
import dateFormatter from './utils/dateFormatter'
Vue.prototype.dateFormatter = dateFormatter

// 全局表格日期时间函数
import tableDateFormatter from './utils/tableDateFormatter'
Vue.prototype.tableDateFormatter = tableDateFormatter

// TODO：待一次性引入所有工具类
import stringUtil from './utils/stringUtil'
Vue.prototype.stringUtil = stringUtil

// Base64工具类
const base64Util = require('js-base64').Base64
Vue.prototype.$base64Util = base64Util
// import Vue2OrgTree from 'vue2-org-tree'
// Vue.use(Vue2OrgTree)

// 高亮显示
import Highlight from '@/directive/highlight'
Vue.use(Highlight)

// web socket
import webSocket from '@/utils/webSocket'
Vue.prototype.$webSocket = webSocket

// 消息通知
import { Notification } from 'element-ui'
Vue.prototype.$notification = Notification

// 消息
// import { Message } from 'element-ui'
// Vue.prototype.$message = Message

// 剪贴板
import VueClipboard from 'vue-clipboard2'
Vue.use(VueClipboard)

new Vue({
  el: '#app',
  router,
  store,
  i18n,
  render: h => h(App)
})
